using UnityEngine;
using EchoFramework;

/// <summary>
/// 主菜单界面
/// </summary>
public class MainMenuView : UIViewBase
{
    private EchoButton startBtn;
    private EchoButton settingBtn;
    private EchoButton exitBtn;

    public override void OnAwake()
    {
        base.OnAwake();
        startBtn = prefabBinder.Find("StartBtn").GetComponent<EchoButton>();
        startBtn.onClick.AddListener(OnClickStartBtn);
        settingBtn = prefabBinder.Find("SettingBtn").GetComponent<EchoButton>();
        settingBtn.onClick.AddListener(OnClickSettingBtn);
        exitBtn = prefabBinder.Find("ExitBtn").GetComponent<EchoButton>();
        exitBtn.onClick.AddListener(OnClickExitBtn);
    }
    
    /// <summary>
    /// 点击开始游戏
    /// </summary>
    private void OnClickStartBtn()
    {
        UIViewManager.Instance.OpenWindow(UIViewID.SelectLevelView);
        CloseWindow();
    }

    /// <summary>
    /// 点击设置
    /// </summary>
    private void OnClickSettingBtn()
    {
        UIViewManager.Instance.OpenWindow(UIViewID.SettingView);
    }

    /// <summary>
    /// 点击退出
    /// </summary>
    private void OnClickExitBtn()
    {
#if UNITY_EDITOR
        UnityEditor.EditorApplication.isPlaying = false;
#else
        Application.Quit();
#endif
    }
}